使用Kylin定义Cube，完成Cube的增量构建，并着重说明：如何进行Cuboid剪枝
1).定义数据源
drop table lagou_kylin.dw_sales2;
create table lagou_kylin.dw_sales2(
id string,
channelId string,
productId string,
regionId string,
amount int,
price double
)
partitioned by (dt string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';

-- 加载数据
load data local inpath "/root/kylin/dw_sales1001_data.txt"
into table lagou_kylin.dw_sales2
partition(dt="2020-11-01");

load data local inpath "/root/kylin/dw_sales1002_data.txt"
into table lagou_kylin.dw_sales2
partition(dt="2020-11-02");

load data local inpath "/root/kylin/dw_sales1003_data.txt"
into table lagou_kylin.dw_sales2
partition(dt="2020-11-03");

load data local inpath "/root/kylin/dw_sales1004_data.txt"
into table lagou_kylin.dw_sales2
partition(dt="2020-11-04");

load data local inpath "/root/kylin/dw_sales1005_data.txt"
into table lagou_kylin.dw_sales2
partition(dt="2020-11-05");

load data local inpath "/root/kylin/dw_sales1006_data.txt"
into table lagou_kylin.dw_sales2
partition(dt="2020-11-06");

-- 建表
drop table lagou_kylin.dim_date;
create table lagou_kylin.dim_date(
dateid string,
dayofyear string,
dayofmonth string,
day_in_year string,
day_in_month string,
weekday string,
week_in_month string,
week_in_year string,
date_type string,
quarter string
)ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
-- 加载数据
LOAD DATA LOCAL INPATH '/root/kylin/dim_date1.txt' OVERWRITE
INTO TABLE lagou_kylin.dim_date partition(dt="2020-11-01");

LOAD DATA LOCAL INPATH '/root/kylin/dim_date2.txt' OVERWRITE
INTO TABLE lagou_kylin.dim_date partition(dt="2020-11-02");

LOAD DATA LOCAL INPATH '/root/kylin/dim_date3.txt' OVERWRITE
INTO TABLE lagou_kylin.dim_date partition(dt="2020-11-03");

LOAD DATA LOCAL INPATH '/root/kylin/dim_date4.txt' OVERWRITE
INTO TABLE lagou_kylin.dim_date partition(dt="2020-11-04");

LOAD DATA LOCAL INPATH '/root/kylin/dim_date5.txt' OVERWRITE
INTO TABLE lagou_kylin.dim_date partition(dt="2020-11-05");

LOAD DATA LOCAL INPATH '/root/kylin/dim_date3.txt' OVERWRITE
INTO TABLE lagou_kylin.dim_date partition(dt="2020-11-06");
2).定义Model
   创建Model中指定关联表、关联条件
   创建Model中指定维度字段
   创建Model中指定度量字段
   增量构建的Cube需要指定分割时间列。例如：将日期分区字段添加到维度列中
   将日期分区字段添加到维度列中
3).定义Cube
   选择数据模型及给定义Cube名称
   指定维度
   指定度量
4).构建Cube
   确定起止时间
5).查看Segment
6).增量构建Cube
   构建 Cube 的作业
7).查看对应的Segment
   查看增量构建Cube对应的Segment
8).查询
select t1.dt,
t2.regionname,
sum(t1.price) as total_money,
sum(t1.amount) as total_amount,
max(t1.price) as total_money,
min(t1.amount) as total_amount
from lagou_kylin.dw_sales2 t1 join lagou_kylin.dim_region t2 on 
t1.regionid = t2.regionid
group by t1.dt, t2.regionname
order by dt

select
t1.dt,
t2.regionid,
t2.regionname,
t3.productid,
t3.productname,
sum(t1.price) as total_money,
sum(t1.amount) as total_amount
from
lagou_kylin.dw_sales2 t1
inner join lagou_kylin.dim_region t2
on t1.regionid = t2.regionid
inner join lagou_kylin.dim_product t3
on t1.productid = t3.productid
group by
t1.dt,
t2.regionid,
t2.regionname,
t3.productid,
t3.productname
order by
t1.dt,
t2.regionname,
t3.productname

Cuboid剪枝优化
	Cuboid 特指 Kylin 中在某一种维度组合下所计算的所有数据。
	以减少Cuboid数量为目的的优化统称为Cuboid剪枝。
	在没有采取任何优化措施的情况下，Kylin会对每一种维度的组合进行预计算。
	Cube的剪枝优化是一种试图减少额外空间占用的方法，这种方法的前提是不会明显
影响查询时间。在做剪枝优化的时候： 
        需要选择跳过那些“多余”的Cuboid
		有的Cuboid因为查询样式的原因永远不会被查询到，因此显得多余
		有的Cuboid的能力和其他Cuboid接近，因此显得多余
